home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 22
/
Cream of the Crop 22.iso
/
image
/
scncd410.zip
/
SCANCODE.DOC
< prev
Wrap
Text File
|
1996-09-23
|
77KB
|
2,042 lines
SCANCODE 4.10
TABLE OF CONTENTS
WHAT IS SCANCODE? . . . . . . . . . . . . . . . . . . . . . . . . . 2
HOW TO USE SCANCODE . . . . . . . . . . . . . . . . . . . . . . . . 6
Quiet . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
"String" . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
CodeWord . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
nn (decimal scan code) . . . . . . . . . . . . . . . . . . . . 9
Uninstall . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Delay . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
WaitForText row,column "Text" . . . . . . . . . . . . . . . . 12
WaitForKey <key> . . . . . . . . . . . . . . . . . . . . . . . 14
Loop n . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Repeat . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
THE SCANCODE ENVIRONMENT VARIABLE . . . . . . . . . . . . . . . . . 19
CODE WORDS RECOGNIZED BY SCANCODE . . . . . . . . . . . . . . . . . 20
DECIMAL KEYBOARD SCAN CODES . . . . . . . . . . . . . . . . . . . . 21
HOLDING DOWN MORE THAN ONE KEY AT A TIME . . . . . . . . . . . . . 22
WHAT ARE SCAN CODES? . . . . . . . . . . . . . . . . . . . . . . . 24
HOW SCANCODE WORKS . . . . . . . . . . . . . . . . . . . . . . . . 26
SPECIAL NOTES . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
SCANCODE AND MICROSOFT WINDOWS . . . . . . . . . . . . . . . . . . 31
A WORD FROM THE SPONSOR . . . . . . . . . . . . . . . . . . . . . . 32
OTHER PROGRAMS . . . . . . . . . . . . . . . . . . . . . . . . . . 32
WARRANTY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
REVISION HISTORY . . . . . . . . . . . . . . . . . . . . . . . . . 34
SCANCODE 4.10 Page 1 of 34
WHAT IS SCANCODE?
═════════════════
SCANCODE is a program that lets you "fake" keystrokes from the keyboard
when you are in the middle of another DOS program. The other program
will think you are typing something on the keyboard when you aren't.
You can use SCANCODE to automate the repetitive keystrokes you always
have to type at the beginning, middle, or end of a program.
SCANCODE starts with the same premise as some other programs on the
market, for example PC Magazine's KEY-FAKE. But SCANCODE goes much
further than these other programs. First of all, SCANCODE has several
different ways you can tell it when to "type" something. SCANCODE can
either wait for a specified amount of time, wait for a certain string of
text to appear somewhere on the screen, or wait for you to give it a
signal with the keyboard.
Another difference between SCANCODE and these other programs is that
SCANCODE will "type" ANY keystroke combination you can type from the
keyboard (for example, <Alt>, <CapsLock>, <Shift>-<PrintScreen>, <Ctrl>-
<Alt>-<Del>, or just "regular text"). The other programs are just able
to type "regular text". This is because the other programs use ASCII
codes to stuff the Keyboard Buffer, while SCANCODE simulates keyboard
hardware interrupts. Explaining the difference between the two gets
pretty complicated, and is discussed below under "WHAT ARE SCAN CODES?".
A final difference between SCANCODE and these other programs is that you
can have more than one SCANCODE in memory at the same time. The
different SCANCODES operate independently of each other (in parallel),
so that they can all be "waiting" for something different to happen, or
can all be "typing" different things at the same time. While they
operate independently of each other, they can also "communicate" with
each other to let the other ones know that something happened (see the
Uninstall and WaitForKey Options below). This allows an incredible
amount of flexibility in how you use SCANCODE, including the ability to
"type" different things depending on exactly what your program does.
SCANCODE 4.10 Page 2 of 34
Let's assume, for example, that almost every time you start WordPerfect
5.1, you hit <F5> <Enter> to pull up a directory of existing files.
When WordPerfect first starts, there is always a status line at the
bottom of the screen, with the word "Doc" appearing at row 25, column
53. Using SCANCODE, you can save yourself a couple of annoying
keystrokes by writing a batch file (WP.BAT) as follows:
ECHO OFF
C:
CD\WP
SCANCODE WaitForText 25,53 "Doc", F5, Enter
REM Wait for "Doc" at row 25 column 53, Type <F5>, Type <Enter>
WP
CD\
Every time you start WordPerfect with the above WP.BAT batch file, you
will automatically get a file list.
As another example, let's use Lotus 1-2-3. When you start 1-2-3, there
is a Lotus logo that appears on the screen for about 5 seconds (which
you would just as soon not see). In the older versions of Lotus, if you
strike a key on the keyboard while the logo is on the screen, the logo
will disappear right away (not hanging around for the full 5 seconds).
Also, almost every time you start the program, you do a "/ File
Retrieve" to pull up a list of existing files to pick from. You can
write a batch file (123.BAT) as follows to do the initial keystrokes for
you:
ECHO OFF
C:
CD\LOTUS
SCANCODE Delay 1, Enter, "1", Delay 1, Enter, "/fr"
REM Delay 1 second Delay 1 second
LOTUS
CD\
Every time you start Lotus 1-2-3 with the above 123.BAT batch file, you
will automatically start 1-2-3 and get a file list.
SCANCODE 4.10 Page 3 of 34
As another example, we'll use a (no-name) DOS program that I use
sometimes. To exit the program, you type <Esc>. Then a "promotional"
screen appears, which you have to see for at least 1 second. Then you
have to hit <Esc> again before you REALLY exit the program. Well,
nowadays I start the program with a batch file like this, and I only
have to hit <Esc> one time (and the "promotional" screen flashes by so
fast I don't even notice it):
ECHO OFF
C:
CD\no-name
SCANCODE WaitForKey Esc, Esc, Delay 1, Esc
REM Wait for <Esc> key, Type <Esc>, Delay 1 second, Type <Esc>
no-name
CD\
As yet another example, let's assume your using a DOS program to backup
your hard drive (we'll call it "BACKUP"). You're using the same disks
you used last time you backed up your hard drive, so BACKUP keeps asking
you if you want to overwrite the existing files, and you have to keep
constantly hitting "y" on the keyboard. Needless to say, you get
annoyed - and SCANCODE could be the answer. You could set up a batch
file similar to following and have SCANCODE "type" the y's for you:
ECHO OFF
C:
CD\BACKUP
SCANCODE WaitForText 12,12 "Overwrite [Y/N]?", "y", Repeat
REM Wait for the text, Type <y>, Repeat it
BACKUP
SCANCODE Uninstall
REM Whenever you use Repeat (or a Loop), be sure to put a
REM "SCANCODE Uninstall" at the end of the Batch file like this
CD\
SCANCODE 4.10 Page 4 of 34
As a final example, I will use a personal situation. I had a PC/XT
Turbo clone, which I could toggle between 4.77 MHz and 10 MHz. There
were two ways to switch this speed - one was with a button on the front
of the computer, and the other was from the keyboard with <Ctrl>-<Alt>-
<Grey->. Most of the time I left it at 10 MHz, but there were certain
programs I had (mainly old Games) that required the computer to be
operating at 4.77 MHz.
Before I wrote SCANCODE, every time I used these programs, I would have
to remember that the particular program needed to run at 4.77 MHz, and
then push the button on the front of the computer. When I was through
with the program, I had to remember to push the button again to switch
the computer back to 10 MHz. This was a real pain. After I wrote
SCANCODE, I had batch files similar to the following to automatically
start these programs:
ECHO OFF
CD\program
SCANCODE Ctrl-Alt-Grey-
REM Toggle to 4.77 MHz
program
SCANCODE Ctrl-Alt-Grey-
REM Toggle back to 10 MHz
CD\
Just so you know, most computers these days still have a "slow" mode and
a "fast" mode. Most newer computers I've seen use Ctrl-Alt-Grey- to
toggle to the "slow" mode, and Ctrl-Alt-Grey+ to toggle to the "fast"
mode.
I will leave it to your imagination as to how many ways you can use
SCANCODE.
SCANCODE 4.10 Page 5 of 34
HOW TO USE SCANCODE
═══════════════════
NOTE: As of version 3.00, the command line Options for SCANCODE no
longer work like they did in versions 1.x and 2.x. If you have existing
batch files that have SCANCODE commands in them, you may need to edit
the batch files to work correctly with newer versions of SCANCODE.
The syntax for using SCANCODE is as follows:
SCANCODE [Q | Quiet] [T | Tbl | Table] scancode1 [scancode2] ...,
where the "scancodes" are either keyboard Scan Codes that SCANCODE will
use to "fake" keyboard hardware interrupts, or special codes to tell
SCANCODE to wait for something to happen before continuing. The
individual Scan Codes can be separated by spaces or by commas. For
example, "SCANCODE W1 1'File''A'" works the same as
"SCANCODE WaitForText 1,1 'File', 'A'". The second one is, I hope, much
easier to read and understand. If you don't enter any Scan Codes, or
try to enter something that SCANCODE doesn't understand, you will get an
error message.
In general, the Options can either be in upper case or lower case
("Quiet" is the same Option as "QUIET" or "QuiEt"). The exception to
this, usually, is something enclosed in quotes ("Text"). If you read
the details in the command line Options below, it should be fairly clear
when something you type is case sensitive or not (SCANCODE only makes
things case sensitive when it needs to).
Note also that there are usually several different ways to enter the
same Option. For example, to be Quiet, you can either type "SCANCODE Q"
or "SCANCODE Quiet". The Options have a "shorthand" code ("Q") and one
or more "longhand" codes ("Quiet"). The "shorthand" codes take up much
less room and are easier to type, but the "longhand" codes are probably
easier to remember and to read. You can use whichever makes the most
sense to you.
SCANCODE 4.10 Page 6 of 34
Q
Quiet
The "Q" (or "Quiet") is optional, and if there tells SCANCODE to
be QUIET (to not send its opening message about who wrote the
program to the screen). SCANCODE always sends error messages to
the screen; the "Q" just tells SCANCODE to be QUIET as long as
everything is OK.
T
Tbl
Table
The "T" (or "Tbl" or "Table") is also optional, and if there
tells SCANCODE that you want a TABLE of decimal Scan Codes shown
on the screen. This lets you use SCANCODE as an on-line
reference for Scan Codes. If you tell SCANCODE you want it to
show you a TABLE, it pretty much ignores anything else you tell
it to do and just shows you the TABLE. For example, if you typed
"SCANCODE Table Enter", SCANCODE would show you the TABLE of Scan
Codes, but would never install itself into memory to "type" the
<Enter> key.
SCANCODE 4.10 Page 7 of 34
There are three different ways to tell SCANCODE what to "type":
'String'
"String"
A string enclosed in single or double quotes. Inside the quotes
can be any series of valid ASCII characters (all the letters and
numbers, spaces, and `~!@#$%^&*()-_=+\|[]{};:'",.<>/?). SCANCODE
has an internal table it uses to translate these ASCII characters
into their equivalent Scan Codes (for example, if you enter a
"$", SCANCODE "types" a <Shift>-<4>).
Note also when entering characters that SCANCODE ignores the
state of any other keys (of particular importance are the
CapsLock and NumLock keys). For example, if you tell SCANCODE to
do an "ST", SCANCODE does a <Shift>-<s>, <Shift>-<t>, which is
normally an "ST". However, if you have CapsLock turned on while
SCANCODE is doing its thing, <Shift>-<s>, <Shift>-<t> will become
"st", not "ST".
CodeWord
A Code Word for one of the keys on the keyboard (for example, F1,
Enter, CapsLock, Shift, Tab, etc.). See the Table below for a
list of Code Words that SCANCODE recognizes.
There are two "special" Code Words that SCANCODE handles a little
differently than the rest of the Code Words - "PrintScreen" and
"Break" (or the allowable variations of these Code Words). The
reason these Code Words require special handling is that what
they should do depends on the situation.
To print the screen with the keyboard from older computers (PC's
and PC/XT's), you have to do a <Shift>-<Grey*>. The keyboard
that comes with newer computers (PC/AT's and newer) has a special
<PrintScreen> key that you don't need to <Shift>. SCANCODE knows
what kind of keyboard you have, and when you enter the
"PrintScreen" Code Word, SCANCODE assumes you want to print the
screen. If you have an old computer, and you give SCANCODE the
"PrintScreen" Code Word, it does a <Shift>-<Grey*>. If you have
a newer computer, SCANCODE does a <PrintScreen>.
Regardless of whether your computer is old or new, in order to
"Break" a program, you have to Enter a <Ctrl>-<Break>; the
<Break> key all by itself does not "Break" anything. If you
enter the "Break" Code Word (or allowable variations of "Break"),
SCANCODE automatically does a <Ctrl>-<Break>. If you study the
Decimal Scan Code Table below, you will see that <Ctrl>-<Break>
on older computers (PC's and PC/XT's) is handled differently than
it is on newer computers. Again, SCANCODE knows whether your
computer is old or new, and handles all of the details
automatically - you just have to give SCANCODE the "Break" Code
Word.
SCANCODE 4.10 Page 8 of 34
nn (decimal scan code)
A decimal Scan Code (see the Tables below for a list of decimal
Scan Codes you can use). This is how you tell SCANCODE to enter
"unusual" keystrokes or keystroke combinations that you can't
enter with a String or a Code Word. The Strings and Code Words
will handle nearly all common situations, so you shouldn't need
to enter decimal Scan Codes very often. For example,
"SCANCODE 29-01" would be the same as "SCANCODE Ctrl-Esc".
A decimal Scan Code of 0 (or the Code Word "Release") tells
SCANCODE to do the "release" Scan Codes for any "push" Scan Codes
it hasn't released yet. This is a holdover from the previous
versions of SCANCODE, and will probably not be too useful any
more (see the sections below on "HOLDING DOWN MORE THAN ONE KEY
AT A TIME" and "WHAT ARE SCAN CODES?").
SCANCODE 4.10 Page 9 of 34
You can remove any old SCANCODEs you have in memory, in case you don't
need them or want them any more:
U
Uninstall
Either of these will disable and UNINSTALL from memory any
previous SCANCODEs that are still in memory. SCANCODE is a TSR
(Terminate and Stay Resident) program that remains in memory as
long as it takes to "do its thing", and then tries to UNINSTALL
itself from memory. Sometimes a SCANCODE will remain in memory
for a very long time (perhaps forever - see the "Loop n",
"Repeat", and "WAIT row col 'Text'" Options below) before it
considers itself done. If you put a SCANCODE in memory to do
something, and then change your mind, decide you have made a
mistake, or for some other reason want to "turn it off", this is
how you do it. "SCANCODE U" or "SCANCODE Uninstall" will "turn
off" and UNINSTALL any previous SCANCODEs that are still in
memory.
SCANCODE does not UNINSTALL the previous SCANCODES in memory
until it gets to the "Uninstall" portion of the command line.
For example, if you type:
SCANCODE Enter, Delay 10, Uninstall, Enter
SCANCODE "types" an <Enter>, waits 10 seconds, then UNINSTALLs
any previous SCANCODES that were in memory, and then "types"
another <Enter>. This is one way different SCANCODEs in memory
can communicate with each other. See the "SPECIAL NOTES" section
below for examples on how you can use this Option to build some
sophisticated batch files.
If you use SCANCODEs in your batch files a lot, you may want to
put a "U" or "Uninstall" as the first Option in the first
SCANCODE line of each batch file ("SCANCODE U {rest of
Options}"). This way you will be sure any SCANCODEs left in
memory from previous batch files are disabled and won't screw up
your current program. You may also want to put a simple
"SCANCODE Uninstall" at the end of all your batch files that use
SCANCODE, to make sure SCANCODEs from this batch file won't
affect future programs.
SCANCODE 4.10 Page 10 of 34
You can also have SCANCODE wait for certain things to occur before it
types something:
D nn
Dly nn
Delay nn
Any of these three Options tells SCANCODE to DELAY for
approximately nn seconds before continuing on. Nn can be between
1 (1 second) and 3600 (approximately 1 hour). This DELAY is
useful for programs that have a built-in delay at the beginning,
during which you can't do anything. For example, some programs
show a fancy logo on the screen for several seconds at the
beginning of the program. During this logo time, you can't do
anything, and the program ignores any keystrokes you try to enter
while the logo is on the screen. For example, if the logo stays
on for five seconds, and after the logo you want to "type" an
<a>, you can put
"SCANCODE Delay 5, 'a'" as a line in your batch file to start the
program.
If you have a DELAY in the middle of a SCANCODE line, and there
are still any "push" Scan Codes still waiting to be released (you
need to read the section below, "WHAT ARE SCAN CODES?", if you
don't understand "push" and "release" Scan Codes), a "Delay nn"
will also act like the key(s) are continually being pushed (a
repeating key). This will simulate a key (or keys) on the
keyboard being held down for "nn" seconds, with the keyboard set
at a repeat rate of approximately 18 characters per second.
After being held down for these "nn" seconds, the keys are
released. For example, "SCANCODE 30-Delay 1" will enter
"aaaaaaaaaaaaaaaaaa" (18 <a>'s), and then release the <a>.
Entering 18 a's at the beginning of a program probably wouldn't
be very useful, but sometimes holding down a Shift key or Ctrl
key while a program is starting is useful.
SCANCODE 4.10 Page 11 of 34
W row,column "Text"
Wait row,column "Text"
WaitFor row,column "Text"
WaitForText row,column "Text"
WaitText row,column "Text"
Text row,column "Text"
TextWait row,column "Text"
Any of these Options tells SCANCODE to WAIT until "Text" appears
on the screen at Row, Column before continuing on. The row and
column numbers can be any number between 0 and 65535. "Text" can
be any character or string of characters, and must be enclosed in
single or double quotes.
Row 1 is at the top of the screen, and column 1 is at the left of
the screen. If you enter a 0 for either the row or column
number, you are telling SCANCODE to search in ALL rows or columns
for "Text". For example, "SCANCODE WaitFor 1,0 'File'" will
search for the word "File" in row 1, any column. If it finds the
word "File" ANYWHERE in row 1 on the screen, it continues on.
"SCANCODE WaitFor 0,5 'Text'" will look for the word "Text" on
all rows, but the "T" in "Text" must start in column 5.
"SCANCODE WaitFor 0,0 'C'" will search the ENTIRE SCREEN for the
letter "C". If it finds a "C" anywhere on the screen, it will
continue on.
Keep in mind that takes SCANCODE a LOT longer to search an entire
row, entire column, or especially an entire screen, than it does
to search just one specific location on the screen for a match.
Your computer can't be doing anything else while SCANCODE is
searching for the "Text". If you have a fast computer, you may
not even notice it. If you have a slow computer, though, you may
not want to put 0's in the row and column numbers if you don't
have to. I realize that counting rows and columns can be a huge
pain, but is worth it if you want to keep things hopping along.
The "Text" SCANCODE is Waiting For must all be in the same row on
the screen. For instance, if you type "SCANCODE W 0,0 'Text'",
and there is "T" at the end of row 1, and "ext" at the beginning
of row 2, it is NOT a match.
Whatever you have inside the quotes is case-sensitive. That is,
if you type "SCANCODE WaitFor 1,1 'Text'", and on the screen at
row 1, column 1 is "TEXT", it is NOT a match.
Having SCANCODE WAIT like this is useful for programs that have a
variable-length delay at the beginning, during which you can't do
anything. For example, some programs show their logo on the
screen for any number of seconds at the beginning of the program.
During this logo time, the program is loading a file (or
something), and the program ignores anything you type from the
keyboard. When the logo finally disappears, the normal "program"
screen appears with a menu line somewhere on the screen, and you
can start to use the keyboard again.
SCANCODE 4.10 Page 12 of 34
For example, say you have a program that can take anywhere from 1
second to 5 minutes to start, depending on how big the file is
that you told it to load. When the program finally starts, it
has a menu line at the top of the screen, and the first item in
the menu (at row 1, column 1 on the screen) is "File". As soon
as the program starts, you want to type "Start of Text". You can
do this all automatically with SCANCODE and a batch file as
follows:
ECHO OFF
CD \PROGRAM
SCANCODE WaitForText 1,1 "File", "Start of Text"
PROGRAM File_To_Load
CD \
SCANCODE will WaitForText patiently (perhaps forever) until the
word "File" appears on the screen at row 1, column 1. If the
word "File" never appears, SCANCODE never goes any further (if
something like this happens, you can UNINSTALL SCANCODE with the
"U" Option discussed above).
Before SCANCODE can test the screen to see if it matches the
"Text", there are a couple of things that must happen first.
First of all, the screen must be in a "text" mode, not a
"graphics" mode; and secondly, the row and column numbers must
exist.
When the screen is in a graphics mode, all SCANCODE can see is
individual dots (pixels) on the screen. There is no way SCANCODE
can reliably tell what a "row of text" is when all it can see is
a bunch of dots (for example, a simple CGA screen is 200x320
pixels, for a total of 64,000 pixels - each of which is stored
individually). In a "text" mode, however, the screen is stored
as a bunch of characters (a standard screen of 25 rows by 80
columns is stored as 2000 characters). This doesn't mean that a
program can't use graphics at all, but as long as the screen is
in a graphics mode, SCANCODE can't do any WaitForText testing,
and will just keep Waiting.
There are many different sizes of screens in "text" mode. So far
in my life, I have seen anywhere from 12 to 63 rows, and anywhere
from 40 to 132 columns. SCANCODE can handle any size. However,
the row and column numbers you give SCANCODE must exist before
SCANCODE can test the "Text". If you enter, for example,
"SCANCODE W 12 150 'Text'", and the screen never has at least 12
rows and 153 columns, SCANCODE will never be able to find a
match.
SCANCODE lets you enter any number between 0 and 65535 for the
row and column numbers, but has no way of telling what a
"reasonable" maximum number is - that depends on exactly what
kind of computer you have. It is up to you to not enter any row
or column number that will never exist. SCANCODE will keep
Waiting (forever, if necessary) until the screen has at least as
many rows and columns as are necessary to test the "Text".
SCANCODE 4.10 Page 13 of 34
K <key>
Key <key>
KeyWait <key>
WaitKey <key>
WaitForKey <key>
Any of these Options tells SCANCODE to wait for <key> to be
pressed on the keyboard. <key> can be any SINGLE key on the
keyboard except <PrintScreen>. It can be entered either as a
single character in quotes (SCANCODE WaitForKey "c"), a CodeWord
(SCANCODE K RCtrl), or as a decimal scan code (SCANCODE Key 1).
Multiple-keystrokes (such as "SCANCODE Key Ctrl-C") are not
allowed.
When entering a single character in quotes, such as
"SCANCODE Key 'C'", SCANCODE treats upper-case and lower-case the
same: "C" and "c" are the same <key>. Likewise with the
characters above the number keys at the top of the keyboard: "$"
and "4" are the same <key>.
This Option is useful when, for any number of reasons, the Delay
or WaitForText Options don't work, or you want to tell SCANCODE
yourself (with the keyboard) when it is OK to continue with what
it is doing. You can also use this Option as a way to
"communicate" between different SCANCODE's in memory.
Once SCANCODE has "intercepted" a particular keystroke, it waits
for you to release the key before it continues with what it is
supposed to do. For example, let's say you typed
"SCANCODE Key Ctrl 'Go'". If you were then trying to type a
<Ctrl>-<C> in your program, it would not work. When you press
the <Ctrl> key, SCANCODE would "intercept" it, and the other
program would never see it. You then press the <C> key, which is
seen by your program (without the <Ctrl>). Your program sees a
<C> rather than a <Ctrl>-<C>. You can keep the <Ctrl> key
pressed all day long while you do all kinds of keyboard pounding,
and SCANCODE will be the only program that knows the <Ctrl> is
pressed. When you finally release the <Ctrl> key, SCANCODE
continues on its way and "types" <Shift>-<g> <o>. The <Ctrl> key
then turns into a regular key again and <Ctrl>-<C> works in the
program like it used to.
The point of this is to let you know that if you want to use the
WaitForKey Option, you need to be careful about picking your
<key>. It needs to be a <key> that you won't type by accident at
some inauspicious time in your program where SCANCODE could
really screw something up. Once you type the <key>, you probably
won't be able to stop SCANCODE from doing whatever you told it to
do after the <key> is pressed.
With SCANCODE, the effect of a single keystroke can be amplified
many times. Just keep in mind that it can amplify the good as
well as the bad.
SCANCODE 4.10 Page 14 of 34
Since SCANCODE can use any single key on the keyboard except
<PrintScreen>, you shouldn't have too much difficulty picking a
key that you won't hit by accident. Some good candidates are
<Esc>, <~>, <F11>, <F12>, <Pause>, <ScrollLock>, <NumLock>, and
some of the "math" keys around the numeric keypad on the right
side of the keyboard.
Once the <key> is pressed and released, SCANCODE just continues
on its way with its next command. The <key> is not passed on to
the other program you are running. This means, for example, that
you can use SCANCODE to effectively "remap" your keyboard. Let's
say you did a "SCANCODE Key 'C' 'You typed a C!'". The first
time you hit the <c> key, you would never see a "c". You would
instead see "You typed a C!". The next time you hit the <c>, it
would be a regular "c". Using the LOOP or REPEAT Options below,
you could do a more permanent "remap" of your keyboard. Read
about these Options below for more details.
The WAITFORKEY Option is also a way to "communicate" between
different SCANCODEs in memory. That is, anything typed by one
SCANCODE can be "intercepted" as a <key> by another SCANCODE,
just as if you typed it on the keyboard yourself. For example,
let's say you typed the following two lines:
SCANCODE Delay 10, "k", WaitForKey F1, "15"
SCANCODE WaitForKey "k", Delay 5, F1
The first SCANCODE waits ten seconds, "types" a <k>, and then
starts waiting for an <F1>. The second SCANCODE intercepts the
<k> generated by the first SCANCODE, waits five seconds, and
"types" an <F1>. The first SCANCODE intercepts the <F1>, and
"converts" it to a "15". The only thing that would end up
getting "typed" to the screen is the "15", and it would happen
about 15 seconds after you started. There are more complicated
and intricate examples of this kind of interaction between
different SCANCODEs in the section below, "SPECIAL NOTES".
SCANCODE 4.10 Page 15 of 34
Normally, after a SCANCODE gets through with what it's supposed to do
one time, it tries to remove itself from memory. There are two ways
you can have SCANCODE keep repeating itself over again instead of just
stopping at the end of the line:
L n
Loop n
Either of these Options tells the SCANCODE to LOOP and do the
SCANCODE line a total of n times, rather than just one time. N
can be any number between 1 and 65535. For example, if you
typed:
SCANCODE Delay 1, "Now", Delay 4, Loop 3
SCANCODE would delay 1 second, type "Now", delay 5 (4+1) seconds,
type "Now", delay 5 seconds, type "Now" again, wait 4 seconds,
and then uninstall itself from memory. You would see
"NowNowNow".
The "Loop n" can be anywhere on the SCANCODE line, not just at
the end. Also, if you enter "Loop n" more than once, SCANCODE
just uses the last one you entered. For example, the following
three lines are equivalent:
SCANCODE Loop 5, "Type This!", Loop 3
SCANCODE Loop 3, "Type This!"
SCANCODE "Type This!", Loop 3
If you are using a LOOP (or a REPEAT) along with the WAITFORTEXT
Option, it is usually a good idea to put a small DELAY at the
beginning or end of the line, as follows:
SCANCODE Delay 1, WaitForText 10,10 "Hit <Esc>", Esc, Loop 25
or:
SCANCODE WaitForText 10,10 "Hit <Esc>", Esc, Delay 1, Loop 25
rather than this:
SCANCODE WaitForText 10,10 "Hit <Esc>", Enter, Loop 25
This is because some programs are relatively slow in reacting to
keystrokes (like this <Esc> key) and won't update the screen
right away (by removing the "Hit <Esc>" from the screen). After
SCANCODE types the <Esc> key in the third line above (without the
DELAY), it will, within about 1/10 of a second, start looking for
"Hit <Esc>" on the screen again. If the program hasn't had time
to get rid of the "<Hit Esc>" from the screen yet after SCANCODE
typed the first <Esc> key, SCANCODE will type <Esc> again.
Basically, SCANCODE will type the <Esc> key twice for just one
"Hit <Esc>" on the screen. This would probably cause all sorts
of headaches for you. Putting in the Delay allows the program
time to update the screen properly so that SCANCODE doesn't
"overreact".
SCANCODE 4.10 Page 16 of 34
If you are in the middle of LOOPing and, for some reason, need to
get out of the LOOP early, you will need to type a "SCANCODE U"
or "SCANCODE Uninstall". See the UNINSTALL Option above for more
details.
If you tell SCANCODE to LOOP one time ("SCANCODE Loop 1") it's
just like you never entered "Loop" at all. Likewise, a
"Loop 65535" is, for most practical applications I can imagine,
the same thing as an infinite LOOP. The REPEAT Option below,
however, is a truly infinite LOOP.
If you have a LOOP and a REPEAT on the same SCANCODE line (for
example, "SCANCODE 'Text', Loop 2, Repeat"), SCANCODE will ignore
the LOOP and just do the REPEAT.
I expect the most useful kind of program for a LOOP or a REPEAT
would be some sort of Backup Program or Anti-Virus program.
These programs many times will keep prompting you on the screen
every time they come across a "special" file (one that's already
been backed up or one that it thinks may have a virus). As long
as the program is a DOS program that runs in text mode on the
screen, you can use SCANCODE with the LOOP or REPEAT Options to
automatically respond to the screen prompts for you. SCANCODE
will keep "typing" in the appropriate key(s) for you, no matter
how many times the screen prompt appears.
You could also use SCANCODE along with the LOOP or REPEAT Options
to "remap" your keyboard "permanently" during a particular
program. For example, say you use a program (call it "program")
where the Help key is <F3>, but you want it to be <F1> so you can
remember it easier. As long as the <F1> key isn't already used
for something in the program, you could set up the following
batch file so that every time you hit <F1> the program will think
you hit the <F3> key instead:
ECHO OFF
CD\program
SCANCODE WaitForKey F1, F3, Loop 65000
program
SCANCODE Uninstall
CD\
Using multiple WAITFORKEYs in the same batch file along with
LOOPs or REPEATs requires some special considerations. See the
"SPECIAL NOTES" section below for a discussion of this.
SCANCODE 4.10 Page 17 of 34
R
Repeat
Either of these Options tells SCANCODE to keep REPEATing the
SCANCODE line indefinitely. There are only two ways you can stop
the SCANCODE line from REPEATing itself over and over again. You
can either turn off the computer, or you can type a "SCANCODE U"
(or "SCANCODE Uninstall").
The REPEAT option works exactly the same as the LOOP Option,
except that with the REPEAT Option SCANCODE will NEVER stop all
by itself (you MUST type a "SCANCODE U" or "SCANCODE Uninstall").
Read the section directly above on the LOOP Option for details,
examples, and cautions - just replace "Loop n" with "Repeat" and
everything applies just the same. There is also an example of
using the REPEAT Option above in the section "WHAT IS SCANCODE?".
I hope you see that with a little ingenuity, SCANCODE can be a very
powerful tool.
SCANCODE 4.10 Page 18 of 34
THE SCANCODE ENVIRONMENT VARIABLE
═════════════════════════════════
In addition to these command line Options, SCANCODE also looks for an
environment variable named SCANCODE. If this environment variable
exists, it must be equal to "Q" or "QUIET", and permanently tells
SCANCODE to be QUIET (the same thing as the "QUIET" command line
Option listed above). To tell SCANCODE to always be QUIET, type
"SET SCANCODE=Q" or "SET SCANCODE=QUIET" from the DOS command line
before you use SCANCODE for the first time (in your AUTOEXEC.BAT file,
for instance). See your DOS book or some other book you trust if you
need more information on what an "environment" is and what it is used
for.
SCANCODE 4.10 Page 19 of 34
╔═══════════════════════════════════════════════════════════════════════╗
║ CODE WORDS RECOGNIZED BY SCANCODE ║
╠═══════════════════════════════════════════════════════════════════════╣
║ Alt, LeftAlt, LftAlt, LtAlt, LAlt ║
║ BackSpace, BackSp, BkSpace, BkSp ║
║ Break, Brk ** SEE SPECIAL NOTES ** ║
║ CapsLock, CapsLk, CapLock, CapLk ║
║ Control, Ctrl, Ctl, LeftControl, LeftCtrl, LeftCtl, LftControl, ║
║ LftCtrl, LftCtl, LtControl, LtCtrl, LtCtl, LControl, LCtrl, LCtl ║
║ Delete, Del ║
║ Down, Dn ║
║ End ║
║ Enter, Return, Rtn, Ret ║
║ Escape, Esc ║
║ F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12 ║
║ Grey+, Gry+, G+, Grey-, Gry-, G-, Grey*, Gry*, G*, Grey/, Gry/, G/ ║
║ Grey5, Gry5, G5 ║
║ GreyDelete, GreyDel, GryDelete, GryDel, GDelete, GDel ║
║ GreyDown, GryDown, GDown, GreyDn, GryDn, GDn ║
║ GreyEnd, GryEnd, GEnd ║
║ GreyEnter, GryEnter, GEnter ║
║ GreyHome, GryHome, GHome ║
║ GreyInsert, GreyIns, GryInsert, GryIns, GInsert, GIns ║
║ GreyLeft, GryLeft, GLeft ║
║ GreyPageDown, GreyPageDn, GreyPgDown, GreyPgDn, GryPageDown, ║
║ GryPageDn, GryPgDown, GryPgDn, GPageDown, GPageDn, GPgDown, GPgDn ║
║ GreyPageUp, GreyPgUp, GryPageUp, GryPgUp, GPageUp, GPgUp ║
║ GreyReturn, GreyRtn, GreyRet, GryReturn, GryRtn, GryRet, ║
║ GReturn, GRtn, GRet ║
║ GreyRight, GryRight, GRight, GreyRt, GryRt, GRt ║
║ GreyUp, GryUp, GUp ║
║ Home ║
║ Insert, Ins ║
║ Left, Lft, Lt ║
║ NumLock, NumLk ║
║ PageDown, PageDn, PgDown, PgDn ║
║ PageUp, PgUp ║
║ Pause ║
║ PrintScreen, PrintScrn, PrintScn, PrintScr, PrtScreen, PrtScrn, ║
║ PrtScn, PrtScr ** SEE SPECIAL NOTES ** ║
║ Release, Rls ** SEE SPECIAL NOTES ** ║
║ Right, Rt ║
║ RightAlt, RtAlt, RAlt ║
║ RightControl, RightCtrl, RightCtl, RtControl, RtCtrl, RtCtl, ║
║ RControl, RCtrl, RCtl ║
║ RightShift, RightSft, RtShift, RtSft, RShift, RSft ║
║ ScrollLock, ScrollLk, ScrlLock, ScrlLk ║
║ Shift, Sft, LeftShift, LeftSft, LftShift, LftSft, ║
║ LtShift, LtSft, LShift, LSft ║
║ Space ║
║ SystemRequest, SystemReq, SystemRq, SysRequest, SysReq, SysRq ║
║ Tab ║
║ Up ║
╚═══════════════════════════════════════════════════════════════════════╝
SCANCODE 4.10 Page 20 of 34
DECIMAL KEYBOARD SCAN CODES (STANDARD KEYBOARD)
╔══╤══════╦══╤═══════╦══╤══════╦══╤═══════╦══╤════════╦══╤════════╗
║ │ ║16│ q ║32│ d ║48│ b ║64│ F6 ║80│ Down ║
║ 1│ Esc ║17│ w ║33│ f ║49│ n ║65│ F7 ║81│ PgDn ║
║ 2│ 1 ║18│ e ║34│ g ║50│ m ║66│ F8 ║82│ Ins ║
║ 3│ 2 ║19│ r ║35│ h ║51│ , ║67│ F9 ║83│ Del ║
║ 4│ 3 ║20│ t ║36│ j ║52│ . ║68│ F10 ║84│ SysReq ║
║ 5│ 4 ║21│ y ║37│ k ║53│ / ║69│ NumLk ║85│ ║
║ 6│ 5 ║22│ u ║38│ l ║54│ RSft ║70│ ScrlLk ║86│ ║
║ 7│ 6 ║23│ i ║39│ ; ║55│ Grey* ║71│ Home ║87│ F11 ║
║ 8│ 7 ║24│ o ║40│ ' ║56│ Alt ║72│ Up ║88│ F12 ║
║ 9│ 8 ║25│ p ║41│ ` ║57│ Space ║73│ PgUp ║89│ ║
║10│ 9 ║26│ [ ║42│ LSft ║58│ CapLk ║74│ Grey- ║90│ ║
║11│ 0 ║27│ ] ║43│ \ ║59│ F1 ║75│ Left ║91│ ║
║12│ - ║28│ Enter ║44│ z ║60│ F2 ║76│ Grey5 ║92│ ║
║13│ = ║29│ Ctrl ║45│ x ║61│ F3 ║77│ Right ║93│ ║
║14│ BkSp ║30│ a ║46│ c ║62│ F4 ║78│ Grey+ ║94│ ║
║15│ Tab ║31│ s ║47│ v ║63│ F5 ║79│ End ║95│ ║
╚══╧══════╩══╧═══════╩══╧══════╩══╧═══════╩══╧════════╩══╧════════╝
DECIMAL KEYBOARD SCAN CODES (ENHANCED KEYBOARD)
╔═══════════════╤═══════════╦════════╤═══════════╦════════╤══════════╗
║ 224-28 │ GreyEnter ║ 224-71 │ GreyHome ║ 224-80 │ GreyDown ║
║ 224-29 │ RightCtrl ║ 224-72 │ GreyUp ║ 224-81 │ GreyPgDn ║
║ 224-42-224-55 │ PrtScr ║ 224-73 │ GreyPgUp ║ 224-82 │ GreyIns ║
║ 224-53 │ Grey/ ║ 224-75 │ GreyLeft ║ 224-83 │ GreyDel ║
║ 224-56 │ RightAlt ║ 224-77 │ GreyRight ║ 225-29 │ Pause ║
║ (Ctrl)-224-70 │ Ctrl-Brk ║ 224-79 │ GreyEnd ║ │ ║
╚═══════════════╧═══════════╩════════╧═══════════╩════════╧══════════╝
SCANCODE 4.10 Page 21 of 34
HOLDING DOWN MORE THAN ONE KEY AT A TIME
════════════════════════════════════════
Most of the time when you type something on the keyboard, you press and
release keys one at a time. When you use SCANCODE, you normally want it
to do the same thing. For example, if you type "SCANCODE Enter Esc",
SCANCODE pushes the <Enter> key, then releases the <Enter> key, then
presses the <Esc> key, and then releases the <Esc> key. Unless you tell
SCANCODE specifically to wait before releasing a key, SCANCODE
automatically releases a key immediately after it presses it.
There are times, however, when you want to have SCANCODE hold down more
than one key on the keyboard at a time (for example, to do a <Ctrl>-
<Alt>-<Del>). You tell SCANCODE to do this by putting dashes ("-")
between the Scan Codes. For example, "SCANCODE Ctrl-Alt-Del" pushes the
<Ctrl>, <Alt>, and <Del> keys all down at the same time (this would
normally reboot your computer). The same thing holds true if you use
decimal Scan Codes (rather than Code Words). "SCANCODE Ctrl-56-83" or
"SCANCODE 29-56-83" is the same as "SCANCODE Ctrl-Alt-Del".
You cannot directly enter single keys, such as "SCANCODE c". This would
confuse SCANCODE. If you want to enter a single character such as a
<c>, you must enter it in quotes ("SCANCODE 'c'"). You also cannot
directly enter keystroke combinations, such as "SCANCODE h-3", where the
first key in the combination is a letter, number, or other "normal"
character. The first key in a keystroke combination MUST be a Code Word
or a decimal Scan Code (if, for some obscure reason, you wanted to hold
down the <h> and the <3> at the same time, you could either do a
"SCANCODE 35-04" or a "SCANCODE 35-3").
You can, however, enter keystroke combinations such as <Ctrl>-<C>
("SCANCODE Ctrl-C") or <Alt>-<1> ("SCANCODE Alt-1"), where the SECOND
key in the combination is a "normal" character (like a "C" or a "1").
In the second example ("SCANCODE Alt-1"), there could be some confusion
as to whether "SCANCODE Alt-1" is telling SCANCODE to do an <Alt>-<1>
(where the "1" is the <1> key, which has a Scan Code of 2), or an <Alt>-
<Esc> (where the "1" is the Scan Code 1, which is the <Esc> key). If
you give SCANCODE a single number after a dash ("SCANCODE Alt-1"),
SCANCODE assumes it is the key corresponding to the number key (in this
case, the <1> key). If you want SCANCODE to do an <Alt>-<Esc>, you can
type "SCANCODE Alt-01" (or "SCANCODE Alt-Esc"). A two-digit number
after a dash (in this case 01) always signifies to SCANCODE that the
number is a Scan Code, and not one of the number keys on the keyboard.
There is one more little thing you need to know when entering a "normal"
key as the second character in a keystroke combination (for example,
"SCANCODE Ctrl-A" or "SCANCODE Ctrl-a"). "SCANCODE Ctrl-A" (with a
capital "A") and "SCANCODE Ctrl-a" (with a small "a") are EXACTLY the
same to SCANCODE. Telling SCANCODE you want a capital "A" does NOT tell
SCANCODE to push the <Shift> key. If you want do a <Ctrl>-<Shift>-<a>,
you need to type "SCANCODE Ctrl-Shift-A" or "SCANCODE Ctrl-Shift-a".
The same thing holds true for the characters above the number keys on
the keyboard (for example, "SCANCODE Ctrl-@" is exactly the same to
SCANCODE as "SCANCODE Ctrl-2").
SCANCODE 4.10 Page 22 of 34
If you want to do a repeating keystroke (see the section above on the
DELAY command line Option for a further description), you must enter the
DELAY with a "Dly nn" or a "Delay nn" - a "D nn" will not work. For
example, say you want to hold down the <Ctrl> key for 1 second. You
could type "SCANCODE Ctrl-Dly 1" or "SCANCODE 29-Delay 1", but
"SCANCODE Ctrl-D1" would not do what you wanted it to do. "SCANCODE
Ctrl-D1" would do a <Ctrl>-<D>, <Esc>.
SCANCODE 4.10 Page 23 of 34
WHAT ARE SCAN CODES?
════════════════════
When you press (or release) a key on the keyboard, the keyboard
generates what is known as a hardware interrupt. This tells the
computer that the keyboard has a keystroke waiting for it. When the
computer is ready for the keystroke, it asks the keyboard to tell it
which key was pressed or released. The keyboard responds by giving the
computer a Scan Code. Each key on the keyboard has a unique Scan Code
(or set of Scan Codes) when it is pressed, and a different Scan Code (or
set of Scan Codes) when it is released.
The Scan Code is then processed by the BIOS (Basic Input Output System).
Depending on which key was pressed or released, and which key(s) were
pressed or released before that, the BIOS either stuffs an ASCII
character into the keyboard buffer, remembers that the key was a "Shift
Key" (Shift, Alt, Ctrl, CapLk, NumLk, etc.), or performs some other
function (such as printing the screen in the case of <Shift>-
<PrintScreen>).
There is not a 1-to-1 correspondence between Scan Codes and ASCII
characters. For example, the following sequence of keystrokes would
normally generate the ASCII character "A":
Push<Shift>, Push<a>, Release<Shift>, Release<a>.
The following sequence of keystrokes would also generate an "A":
Push<CapsLock>, Release<CapsLock>, Push<a>, Release<a>,
Push<CapsLock>, Release<CapsLock>.
The Tables above list the Scan Codes that a keyboard generates when a
key is Pushed on the keyboard. A different Scan Code is generated when
the key is Released (usually, it is the Push Scan Code plus 128). For
example, when you Push the <Esc> key, the keyboard generates the Scan
Code 1. If you keep holding down the <Esc> key, the keyboard will keep
generating Scan Codes of 1. When you finally release the <Esc> key, the
keyboard generates a Scan Code of 129. SCANCODE knows how to calculate
all of the Return Scan Codes.
You tell SCANCODE which Push Scan Codes to use and when to do the
Release Scan Codes (actually, to be fair, you tell SCANCODE when to NOT
do the Release Scan Codes - see the section above on "HOLDING DOWN MORE
THAN ONE KEY AT A TIME"). This sounds complicated, so let's give an
example. Let's use SCANCODE to enter an ASCII "A" using the two
different keystroke sequences shown above. We'll use "P" for Push and
"R" for Release.
SCANCODE Shift - a
REM P<Shift> P<a> R<Shift, a>
SCANCODE CapsLock "a" 58
REM P<CapsLock> R<CapsLock> P<a> R<a> P<CapsLock> R<CapsLock>
SCANCODE 4.10 Page 24 of 34
As another example, let's hold down the shift key for ten seconds
(making everything you type for the next ten seconds be capitalized):
SCANCODE LeftShift - Delay 10
REM P<LeftShift> <Hold it down for 10 seconds, R<LeftShift>>
As a last example, let's wait 1 minute and then reboot the computer with
<Ctrl>-<Alt>-<Del> (this could be a nasty line to put in somebody's
AUTOEXEC.BAT file):
SCANCODE Delay 60 Ctrl - Alt - Del
REM <Delay 60 seconds> P<Ctrl> P<Alt> P<Del> R<Ctrl, Alt, Del>
SCANCODE 4.10 Page 25 of 34
HOW SCANCODE WORKS
══════════════════
As discussed above, SCANCODE is a TSR (Terminate and Stay Resident)
program. SCANCODE temporarily installs itself into memory, does its
DELAY, WAIT, and keystroke things, and then UNINSTALLs itself from
memory (if it can). While it is installed in memory, SCANCODE uses
approximately 2800 bytes of RAM. Again, SCANCODE only uses this memory
as long as it needs it to do its stuff, and then it gives the memory
back to DOS so that other programs can use it.
SCANCODE ties itself to the timer interrupt of the computer, which
occurs approximately 18 times per second. Every time this timer
interrupt occurs, SCANCODE does something. It either does a series of
keystroke "presses", a series of keystroke "releases", or does nothing
(if it is in the middle of a Delay or a Wait). For example:
SCANCODE "A" "s" "k"
REM P<Shift, a> R<Shift, a> P<s> R<s> P<k> R<k>
would do a <Shift>-<a>, wait 1/18 of a second, release the <Shift>-<a>,
wait 1/18 of a second, do an <s>, wait 1/18 of a second, release the
<s>, wait 1/18 of a second, do a <k>, wait 1/18 of a second, release the
<k>, wait 1/18 of a second, then remove itself from memory.
SCANCODE 4.10 Page 26 of 34
SPECIAL NOTES
═════════════
SCANCODE tries to "fake" programs out by simulating keyboard hardware
interrupts. SCANCODE gives the computer keyboard Scan Codes (with
software) that the computer thinks came from the keyboard hardware.
This is something that the computer isn't supposed to be able to do, and
unfortunately, it doesn't always work correctly. There are only a few
programs that don't work with SCANCODE. You will just have to try it
and see.
SCANCODE will let you enter as many Scan Codes as you can enter from the
DOS command line (the DOS command line is 128 characters long). If that
isn't enough Scan Codes for whatever you're trying to do, you will have
to use SCANCODE more than once. If you use it more than once, and you
want to make sure the first one is done before the second one starts,
you will need to "communicate" between the two SCANCODEs. You can
either put a Delay, WaitForText, or WaitForKey at the beginning of the
second SCANCODE to make sure the first one is done before it starts (see
the examples below).
SCANCODE doesn't use a lot of memory (about 2800 bytes). It does use
enough that you might have some concern, however, especially if you want
to load several SCANCODEs into memory at the same time. You can use the
LOADHI (or LH) DOS commands to load SCANCODE into High Memory if you
want to save Conventional Memory for your other programs. SCANCODE
works fine in High Memory.
If you read the section above, "HOW SCANCODE WORKS", it says that the
timer interrupt occurs approximately 18 times per second. The exact
number of times it occurs is 18.21 times per second. When calculating
how long wait during a Delay, SCANCODE multiplies the number of
"seconds" you tell it to Delay by 18 (not 18.21), and Delays for that
many timer interrupts to happen. There is enough discrepancy between 18
and 18.21 that SCANCODEs timing is not exact. If you tell SCANCODE to
Delay for 60 "seconds", it will actually Delay for (approximately) 59.3
seconds. If you tell SCANCODE to Delay the maximum of 3600 "seconds",
it will actually Delay for 59 minutes and 19 seconds (approximately).
The bottom line is that the Delay times are approximate, no exact. They
are close enough, though, that under normal circumstances it is not a
concern.
SCANCODE 4.10 Page 27 of 34
Let's assume you had the following SCANCODEs in memory:
SCANCODE Delay 10, F1
SCANCODE Delay 01, Enter
SCANCODE Delay 5, Uninstall, "Done"
The first SCANCODE line will try to Delay for 10 seconds and then "type"
an <F1>. The second line will try to "type" an <Enter> after only one
second. The last line will Uninstall ("turn off" or "disable") the
other two lines after five seconds, and then type "Done". The end
result of this series would be that the second line would "type" <Enter>
after one second; then the third line would Uninstall the first two
lines four seconds later; then the third line would type "Done". The
first line would never get a chance to "type" <F1>.
If you have more than one SCANCODE in memory, it is also possible to
have more than one of them WaitForText-ing (or WaitForKey-ing) for the
SAME "Text" (or <key>). It is also possible to have more than one
SCANCODE trying to "type" something at the same time. When this is the
case, the LAST SCANCODE in memory is the one that goes first. This can
get really complicated, so see if you can follow me. Let's say you had
the following SCANCODES in memory:
SCANCODE WaitText 1,1 "File", "A", WaitKey "B", "22"
SCANCODE WaitKey F2, F1
SCANCODE WaitKey F1, Uninstall, "B", WaitKey "2", "25"
SCANCODE WaitText 1,1 "F", WaitKey "A", F2, WaitKey "B", U, "21"
If the string "File" appeared on the screen at row 1, column 1, this is
what would happen. The last SCANCODE would see the "F" in "File", and
then start waiting for an <a> key. The third SCANCODE is waiting for an
<F1>. The second SCANCODE is waiting for an <F2>. The first SCANCODE
sees the word "File", "types" a <Shift>-<a>, and then starts waiting for
a <b>. The last SCANCODE then goes again, sees the <a> that was typed
by the first SCANCODE, "converts" it to an <F2>, and then waits for a
<b>. The third SCANCODE is still waiting for an <F1>. The second
SCANCODE sees the <F2> "typed" by the last SCANCODE, "converts" it to an
<F1>, and then removes itself from memory. The first SCANCODE is still
waiting for a <b>. We then go to the last SCANCODE again. The last
SCANCODE is still waiting for a <b>. The third SCANCODE sees the <F1>
"typed" by the second SCANCODE, Uninstalls (disables) the first two
SCANCODES from memory, and then "types" a <Shift>-<b>. The first two
SCANCODEs have been disabled, so we're back at the last SCANCODE again,
which is waiting for a <b>. It sees the <b> typed by the third
SCANCODE, Uninstalls the third SCANCODE from memory, types a <2> and a
<1>, and then Uninstalls itself from memory.
Whew! If you managed to follow all that, congratulations. This
particular example didn't really do anything useful. Hopefully, it did
show you how different SCANCODEs can "communicate" with each other with
Uninstall's and WaitForKey's, and to maybe start you thinking about all
the wonderful things you can do with your batch files.
SCANCODE 4.10 Page 28 of 34
There are some special considerations you need to keep in mind when
using multiple WAITFORKEY Options at the same time along with the LOOP
or REPEAT Options. Say you had a program where you wanted to switch the
<Control> and <CapsLock> keys with each other. You might be tempted to
try and set up a batch file which included the following lines:
SCANCODE WaitForKey Control, CapsLock, Repeat
REM Turn <Control> into <CapsLock>
SCANCODE WaitForKey CapsLock, Control, Repeat
REM Turn <CapsLock> into <Control>
Unfortunately, this would not switch the <Control> and <CapsLock> keys
for you. Say, for instance, you hit the <Control> key. The first
SCANCODE would "intercept" it, and "type" a <CapsLock>. This would in
turn be "intercepted" by the second SCANCODE, which would then "type" a
<Control>. You might then think that the first SCANCODE would
"intercept" this <Control> and turn it into a <CapsLock>. Normally it
would; however, because of some internal timing issues, the first
SCANCODE has not yet had time to "reset" itself and start looking for
another <Control> key yet. The end result is that the <Control> key you
typed comes back to you unchanged - it just comes back with a slight
delay.
You can use multiple WAITFORKEYs with LOOPs or REPEATs in memory at the
same time, but in general what the <keys> are being changed to and from
must be completely independent of each other among the different
SCANCODEs. The fact that SCANCODEs can interact with each other via
"typed" keys in one way greatly increases their flexibility and
usefulness, yet in another way limits their flexibility and usefulness.
I believe the ability for SCANCODEs to "talk" to each other via "typed"
keys is very useful, even though it limits their ability for you to
"exchange" <keys>.
If you use the WAITFORKEY Option very much, you will notice that there
is a slight delay between when you hit a key and when SCANCODE "types"
its key in response. There is not enough delay to cause problems in
most programs. However, if you're using SCANCODE with a game or
something that requires quick responses from the keyboard, SCANCODE may
have enough delay to cause you some grief. The delay is inherent in the
way SCANCODE works and, unfortunately, can't be changed easily. There
is a slightly more detailed discussion of this above in the section "HOW
SCANCODE WORKS".
SCANCODE 4.10 Page 29 of 34
SCANCODE has no problem at all dealing with environment variables. For
example, say you had the following lines in a batch file:
SET DLY=10
SET TEXT=I found it!
IF EXIST TEST.FIL GOTO DoIt
SET DLY=5
SET TEXT=TEST.FIL does not exist.
:DoIt
SCANCODE Delay %DLY%, "%TEXT%"
SET DLY=
SET TEXT=
If a file called TEST.FIL exists, this batch file will Delay 10 seconds
and then type "I found it!". If the file isn't there, the batch file
will Delay for just 5 seconds and then type "TEST.FIL does not exist".
If SET and IF EXIST and any of the other stuff here is Greek to you, you
need to invest some time in a good DOS book that discusses batch files
and environment variables; it will be well worth your time.
See the special notes above in "HOLDING DOWN MORE THAN ONE KEY AT A
TIME" on the problems you may encounter and why SCANCODE may not be
entering the keys you think it should be entering.
SCANCODE 4.10 Page 30 of 34
SCANCODE AND MICROSOFT WINDOWS
══════════════════════════════
Since Microsoft Windows is so rampant these days, I feel it is necessary
to talk about how SCANCODE works with Microsoft Windows. First of all,
SCANCODE is a DOS program. It does not work at all if you are in
Windows and using a Windows program.
If you are just using Windows as a task-switcher, however, and you are
just shelling out of Windows to run a DOS program, SCANCODE may or may
not work depending on which version of Windows you are using. I have
only been able to test SCANCODE with Windows 3.1 and Windows 95. I have
no idea whether or not SCANCODE will work with any other versions of
Windows (1.x, 2.x, 3.0, 3.11, or any version of NT). I also have no
idea whether or not SCANCODE works with other task-switching or multi-
tasking programs, such as DesqView or the various implementations of
Unix. If someone out there is willing to test this for me and let me
know, I will update the future documentation to reflect this.
If you are just shelled out of Windows and are actually running a DOS
program, the following table tells you whether or not SCANCODE will
work:
Windows 3.1 in Standard Mode: SCANCODE works just fine
Windows 3.1 in Enhanced Mode: SCANCODE does not work at all
Windows 95: SCANCODE works just fine
I just recently started using Window 95, and, quite frankly, was
surprised that SCANCODE worked based on my bad experiences with Windows
3.1. But it does - and I'm not complaining. There are still a lot of
DOS programs out there that people use, even if Microsoft doesn't want
to admit it. Hopefully SCANCODE and other similar programs will make
life easier for you when you are using these "old" DOS programs.
SCANCODE 4.10 Page 31 of 34
A WORD FROM THE SPONSOR
═══════════════════════
SCANCODE is a free program. If you like it and use it, do something
nice for someone else in return. I will accept niceties to myself in
the form of $.
You can freely copy and distribute SCANCODE.COM, as long as it is
distributed along with this SCANCODE.DOC, and neither file has been
modified in any way. You cannot charge anyone in any way for SCANCODE,
except for a small charge to cover your costs for disks and shipping
(you cannot charge for "handling"). You do need my permission to
distribute SCANCODE as a "companion" to some other program.
OTHER PROGRAMS
══════════════
If you like SCANCODE, I have written some other programs you may find
useful.
CLOCK
Shows a clock on your screen all the time. Also has two alarms
that beep at you when it's time for an appointment.
JOYKEYS
Lets you use your joystick(s) with ANY program.
MOUSKEYS
Lets you use your mouse with ANY program.
PRTSCR
Sends all of your PrintScreens to a file instead of a printer. A
good way to transfer data between two programs, even if they won't
normally "talk" to each other.
PRTSCRFF
Modifies your PrintScreen so that each new PrintScreen gets put on
a new sheet of paper (especially useful if you have a Laser
printer).
SERIAL
Shows the status of your serial (COM) ports on screen. Shows the
bit rate, parity, status of the leads (DTR, DSR, etc.). An
excellent way to troubleshoot modem problems.
SLOWDOWN
Slows down a fast computer so you can run older programs that
require a PC/XT or PC/AT.
SCANCODE 4.10 Page 32 of 34
WARRANTY
════════
There is no warranty of any kind, either expressed or implied, supplied
with SCANCODE. As with any software, it may or may not work with other
software that you may have. I have done my best to make sure SCANCODE
won't screw anything up, but, again, there is no guarantee.
If you find any "bugs" in this program, or see something that you wish
were different, please let me know. I can only improve SCANCODE if I
know what you think needs to improve.
HAVE FUN!
Bret Johnson
6775 South Logan Street
Littleton, CO 80122-1249
(303) 795-5084
bretjohn@aol.com
SCANCODE 4.10 Page 33 of 34
REVISION HISTORY
════════════════
04/06/93 v1.00
04/26/94 v2.00
* Changed from executable file to TSR.
* Added DELAY (D nn) Option.
* Added WAIT (W row col "Wait_Text") Option.
* Added QUIET (Q) Option.
* Added UNINSTALL (U) Option.
* Added environment variable support.
05/04/94 v2.01
* Modified the way SCANCODE "fakes" interrupts, making it work with
more programs.
09/08/94 v2.02
* Once again modified the way SCANCODE "fakes" interrupts, making it
work with more programs.
12/15/94 v3.00
* Completely modified the SCANCODE user interface, adding in all of
the Code Words and dashes and effectively eliminating the need for
"Release" codes.
12/30/95 v3.01
* Modified the way the program accesses the computer timer, hopefully
making it more compatible with other programs.
02/04/96 v4.00
* Added KEY (K <key>) Option.
* Changed maximum Delay time from 240 seconds (~4 minutes) to 3600
seconds (~1 hour).
* Improved error checking for command line Options. Now it is harder
to enter "illegal" Options.
* Modified code so that if more than one SCANCODE is in memory, the
later SCANCODEs reuse some of the code from the first SCANCODE.
Later SCANCODEs use approximately 300 bytes less memory than the
first SCANCODE.
* Modified WaitForText Option so that row and column numbers can be 0
(allowing for text to appear anywhere on the screen, not just at a
specific row and column).
* Better recognizes extended text screen modes. Previously there were
special extended video text modes (such as certain ones with 132
columns) that SCANCODE mistook for extended graphics modes.
SCANCODE is now able to recognize these as being text modes.
09/22/96 v4.10
* Added the LOOP and REPEAT Options.
* Did a little bit of "housecleaning" on the code and made it slightly
smaller and faster than before.
SCANCODE 4.10 Page 34 of 34